<template>
  <view class="exam-plan-container">
    <text class="title">培训计划</text>
    <view class="exam-list">
      <view class="exam-item" v-for="exam in examList" :key="exam.id">
        <view class="exam-header">
          <text class="exam-name">{{ exam.name }}</text>
          <text class="exam-nickname">创建人: {{ exam.nickName }}</text>
        </view>
        <text class="exam-description">{{ exam.description }}</text><br/>
        <text class="exam-time">培训时间: {{ exam.startTime }} 至 {{ exam.endTime }}</text>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      examList: []
    };
  },
  onLoad() {
    this.fetchExamPlanData();
  },
  methods: {
    fetchExamPlanData() {
      uni.request({
        url: 'http://127.0.0.1:1004/safety/findAllSafetyPlans', // 替换为实际的 API 地址
        method: 'GET',
        success: (res) => {
          if (res.data.code === 200) {
            this.examList = res.data.data;
          } else {
            console.error('获取考试计划失败:', res.data.msg);
          }
        },
        fail: (err) => {
          console.error('请求失败:', err);
        }
      });
    }
  }
};
</script>

<style lang="scss">
.exam-plan-container {
  padding: 30rpx;
  background: linear-gradient(to bottom, #f8f8f8, #ffffff);
  border-radius: 24rpx;
  box-shadow: 0 6rpx 14rpx rgba(0, 0, 0, 0.08);
}

.title {
  font-size: 38rpx;
  font-weight: bold;
  text-align: center;
  margin-bottom: 40rpx;
  color: #333;
  letter-spacing: 2rpx;
}

.exam-list {
  display: flex;
  flex-direction: column;
  gap: 25rpx; // 调整列表间距
}

.exam-item {
  padding: 32rpx;
  background: #fff;
  border-radius: 24rpx;
  box-shadow: 0 6rpx 18rpx rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease-in-out;
}

.exam-item:hover {
  transform: translateY(-6rpx);
  box-shadow: 0 10rpx 24rpx rgba(0, 0, 0, 0.15);
}

.exam-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20rpx;
}

.exam-name {
  font-size: 32rpx;
  font-weight: bold;
  color: #333;
}

.exam-nickname {
  font-size: 26rpx;
  color: #888;
}

.exam-description {
  font-size: 28rpx;
  color: #555;
  line-height: 1.6;
  margin-bottom: 20rpx;
}

.exam-time {
  font-size: 26rpx;
  color: #777;
  font-style: italic;
}
</style>
